package com.cgsd.heyu.widgets;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.widget.TextView;

import com.android.library.utils.StringUtils;
import com.cgsd.heyu.R;

/**
 * @author xiaoxing
 */
public class CommonProgressDialog extends Dialog {

    private String progressText;

    public CommonProgressDialog(Context context) {
        super(context);
    }

    public CommonProgressDialog(Context context, int theme, String progressText) {
        super(context, theme);
        this.progressText = progressText;
    }

    public CommonProgressDialog(Context context, String text) {
        super(context);
        this.progressText = text;
    }

    public CommonProgressDialog(Context context, String text, boolean canBack) {
        super(context);
        this.progressText = text;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_loading);

        if (StringUtils.isNotEmpty(progressText)) {
            TextView textView = (TextView) findViewById(R.id.mTv);
            textView.setText(progressText);
        }
    }

    public void setDismissListener(OnDismissListener listener) {
        setOnDismissListener(listener);
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        return super.onKeyDown(keyCode, event);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event)   {
        return false;
    }
}
